import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Login from "../views/Login";
import TigList from "../views/TigList";
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: '登录',
    component: Login
  },
  {
    path: '/login',
    name: '登录',
    component: Login
  },
  {
    path: '/list',
    name: '列表',
    component: TigList
  }
]

const router = new VueRouter({
  routes
})

export default router

router.beforeEach(function (to, from, next) {

  if(to.path=="/" || to.path=="/login"){
    return next();
  }
  var user=sessionStorage.getItem("user");
  if(user){
    return next();
  }
  return next("/login");
})
